package lesson14;

import java.util.Scanner;
public class Auction 
{
	int numberOfCars;
	int numberOfPatricipants;
	Car[] cars; //= new Car[numberOfCars];
	Person[] participants; //= new Person[numberOfPatricipants];
	boolean isOpen = false;
	
	void open()
	{
		isOpen = true;
	}
	
	void close()
	{
		isOpen = false;
	}

	void setNumberOfParticipants(Scanner sc)
	{
		System.out.println("Enter number of participants:");
		numberOfPatricipants = sc.nextInt();
		participants = new Person[numberOfPatricipants];
	}
	
	void setNumberOfCars(Scanner sc)
	{
		System.out.println("Enter number of cars:");
		numberOfCars = sc.nextInt();
		cars = new Car[numberOfCars];
	}
	
	void setCars(Scanner sc)
	{
		for (int i = 0; i < cars.length; i++)
		{
			cars[i] = new Car();
			System.out.println("Enter model:");
			cars[i].model = sc.next();
			System.out.println("Enter color:");
			cars[i].color = sc.next();
		}
	}
	
	void setParticipants(Scanner sc)
	{
		for (int i = 0; i < participants.length; i++)
		{
			participants[i] = new Person();
			System.out.println("Enter name:");
			participants[i].name = sc.next();
		}
	}
	
	void listBuyers()
	{
		for (int i = 0; i < cars.length; i++) 
		{
			if(cars[i].owner != null)
			{
				System.out.println(participants[i].name);
				System.out.print("Cars:" + cars[i].model + " ");
				for (int j = i+1; j < cars.length; j++) 
				{
					if(cars[j].owner.equals(cars[i].owner))
					{
						System.out.println(cars[j].model);
					}
				}
			}
		}
	}
}	
